<#include "/common/head.html"/> 
<table id="dg"></table>
<div id="tb" style="padding:2px 5px;">
     <a href="javascript:void(0)" class="easyui-linkbutton addBtn" iconCls="glyphicon-plus" plain="true" onclick="add()">新增</a>
     <a href="javascript:void(0)" class="easyui-linkbutton updateBtn" iconCls="glyphicon-pencil" plain="true" onclick="update()">编辑</a>
     <a href="javascript:void(0)" class="easyui-linkbutton addBtn" iconCls="glyphicon-remove" plain="true" onclick="delete1()">删除</a> 
</div>
<script type="text/javascript">
//查询回显
var datagrid = $("#dg");
var dgOptions = {
        rownumbers:true,
    	fit:true,
    	border:false,
    	striped:true,
        rownumbers:true,
    	url:'listData',
    	method:'post',
    	toolbar:'#tb',
    	pageSize: 20,
    	pagination:true,
    	multiSort:true,
    	singleSelect:true,
        columns: [[
				  {field:'number', title:'编号', width:100}
	           	 ,{field:'loanAmount', title: '借款金额', width:100}
	           ]]
	};
$(function() {
	datagrid.datagrid(dgOptions);
});

//添加
/* function add() {
	top.openWindow("新增通道", getCurrUrl("add"), {size: '800x400'});
}  */
function add() {
	location.replace('add');
}

//修改
function update() {
	var rowsSel = datagrid.datagrid("getSelections");
	if(rowsSel.length != 1) {
		showWarnMsg("请选择一条数据！");
		return;
	}
	var id = rowsSel[0].id;
	location.replace('update?id='+id);
}

//接口详情
function detail(){
	var rowsSel = datagrid.datagrid("getSelections");
	if(rowsSel.length != 1) {
		showWarnMsg("请选择一条数据！");
		return;
	}
	var id = rowsSel[0].id;
	location.replace('detail?id='+id);
}

//删除
function delete1() {
	var rowsSel = datagrid.datagrid("getSelections");
	if(rowsSel.length != 1) {
		showWarnMsg("请选择一条数据！");
		return;
	}
	var id= rowsSel[0].id;
	confirmMsg("确认删除吗？", function() {
		var id = rowsSel[0].id;
		$.post("delete", {id: id}, function(data) {
			var result = data.result;
			if(result=='success'){
				showMsg("删除成功！");
				datagrid.datagrid("reload");
			}else{
				showWarnMsg(result);
        		return;
			}
		});
	});
}
</script>
<#include "/common/dialogWindow.html"/>
<#include "/common/foot.html"/>